package DAO;

import java.util.List;
import java.util.UUID;

import common.Enums.ComponentType;
import common.Enums.DateRange;
import common.Exceptions.DAOException;

import model.*;

public interface MetAppDAO extends BaseDAO<MethodApplication>
{
	 public void insert(UUID bcID, MethodApplication item) throws DAOException;
	 public void update(MethodApplication item) throws DAOException;
	 public void delete(UUID id) throws DAOException;
	 public MethodApplication getByID(UUID id) throws DAOException;
	 public List<MethodApplication> getAll() throws DAOException;
	 
	 /**
	  * Method obtains all the relation of the components to a given Business Case, identified by its ID.
	  * For each related component, its creates all the related component objects instances and encapsulate into a MethodApplication object.
	  * Each method application object has a corresponded component object instance, acting as the central source of the related data.
	  * @param itemID The ID of the Business Case
	  * @return List of MethodApplication objects, used for mapping all the components to each other.
	  * @throws DAOException
	  */
	 public List<MethodApplication> getAllByBcID(UUID itemID) throws DAOException;
	 public List<MethodApplication> getAllByCriterionID(UUID criterionID) throws DAOException;
	 public List<MethodApplication> getAllByCaseAndCriterionID(UUID bcID, UUID criterionID, UUID caseID) throws DAOException;
	 public List<Case> getCasesByBcID(UUID itemID) throws DAOException;
	 public List<Criterion> getCriteriaByBcID(UUID itemID) throws DAOException;
	 public List<Method> getMethodsByBcID(UUID itemID) throws DAOException;
	 public List<Value> getValuesByBcID(UUID itemID) throws DAOException;
	 public List<Value> getValuesByMethodID(UUID itemID) throws DAOException;
	 
	 public boolean assertIsOnlyReference(ComponentType cmpType, UUID cmpID) throws DAOException;
	 public boolean assertIsOnlyCrt(UUID crtID, UUID parentMetID) throws DAOException;
	 /**
	  * Method checks if the given component is reused in others BCs. The method search for the component in the BCs, excluding the one identified by the parameter.
	  * @param cmpType The type of the given component: Case, Value, Method or Criterion.
	  * @param cmpID The ID of the component to be checked.
	  * @param bcID The BC id. This id should be the ID of the current Business Case so that the others BCs will be checked in order to find out if the component is reused or not.
	  * @return True if the component is referenced by others BCs or false otherwise.
	  * @throws DAOException The error that cause the malfunctioning of the method.
	  */
	 public boolean isComponentReused(ComponentType cmpType, UUID cmpID, UUID bcID) throws DAOException;
	 
	 public Value getValue(UUID casID, UUID metID) throws DAOException;
	 public MethodApplication getOriginMetApp(ComponentType cmpType, UUID cmpID) throws DAOException;
	 public List<ComponentWithBC<Case>> getCaseByFilters(UUID bcID, UUID parentBc, DateRange dateRange, String search) throws DAOException;
	 public List<ComponentWithBC<Method>> getMethodByFilters(UUID bcID, DateRange dateRange, String search) throws DAOException;
	 public List<ComponentWithBC<Criterion>> getCriterionByFilters(UUID bcID, UUID parentMetID, DateRange dateRange, String search) throws DAOException;
	 public List<MethodApplication> getValuesByFilters(UUID bcID, DateRange dateRange, String search) throws DAOException;
}
